package com.huhu.listener;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * Created by xuyi on 2016/9/8.
 */
public class MySessionListener implements HttpSessionListener {

    public MySessionListener() {
        super();
    }

    int sessionCount = 0;

    @Override
    public void sessionCreated(HttpSessionEvent httpSessionEvent) {
        String id = httpSessionEvent.getSession().getId();

        sessionCount++;
        System.out.println(sessionCount);
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
        sessionCount--;
    }
}
